<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: 冲塔怪
  Date: 2022/5/1
  Time: 16:45
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>商品管理</title>
    <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    <script type="text/javascript">
        $(function(){
            //给删除的a标签绑定单击事件，防止误触。
            $("a.deleteClass").click(function () {
                return confirm("确认删除吗《"+$(this).parent().parent().find("td:nth-child(2)").text()+"》？");
            });
        });
    </script>
</head>
<body>
<table>
    <tr>
        <td>id</td>
        <td>名称</td>
        <td>价格</td>
        <td>销量</td>
        <td>库存</td>
        <td colspan="2">操作</td>
    </tr>

    <c:forEach items="${requestScope.list}" var="good">
        <tr>
            <td>${good.id}</td>
            <td>${good.name}</td>
            <td>${good.price}</td>
            <td>${good.sales}</td>
            <td>${good.stock}</td>
            <td><a href="${pageContext.request.contextPath}/manage/good?action=getGood&id=${good.id}&method=update">修改</a></td>
            <td><a class="deleteClass" href="${pageContext.request.contextPath}/manage/good?action=delete&id=${good.id}">删除</a></td>
        </tr>
    </c:forEach>
    <tr>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td><a href="${pageContext.request.contextPath}/jsp/manager/good_edit.jsp?method=add">添加图书</a></td>
    </tr>
</table>
</body>
</html>
